package cn.gjculture.shopping.api.entity;

import lombok.Data;
import lombok.Getter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.List;

@Data
public class Commodity {
    private String goodsId;
    private String goodsName;
    private Long updateTime;
    private Long insertTime;
    //status 状态：0,售卖中，1,新建，2，审核通过
    private Integer status;
    private Integer commodityType;
    //原价
    private String price;
    //折扣价
    private String discountPrice;
    //折扣
    private String discount;
    private String superDiscount;
    private String tags;
    private Integer index;
    private String primeCost;
    private String goodsNo;
    private String goodsDesc;
    private String goodsIntroduction;


    private List<Thumbnail> thumbnails;

    public enum CommodityType{
        GOODS(1), HOTEL(2), OIL_CARD(3),ART(5),VIP_GOODS(6);

        CommodityType(Integer value){
            this.value=value;
        }

        @Getter
        private Integer value;
    }

    /**
     * 缩略图
     */
    @Data
    public static class Thumbnail{
        private String goodsId;
        private String fileName;
        private String fileId;
        private String fileUrl;
        private Integer picType;
        public Thumbnail(){}

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;

            if (o == null || getClass() != o.getClass()) return false;

            Thumbnail thumbnail = (Thumbnail) o;

            return new EqualsBuilder()
                    .append(goodsId, thumbnail.goodsId)
                    .append(fileName, thumbnail.fileName)
                    .append(fileId, thumbnail.fileId)
                    .append(fileUrl, thumbnail.fileUrl)
                    .append(picType, thumbnail.picType)
                    .isEquals();
        }

        @Override
        public int hashCode() {
            return new HashCodeBuilder(17, 37)
                    .append(goodsId)
                    .append(fileName)
                    .append(fileId)
                    .append(fileUrl)
                    .append(picType)
                    .toHashCode();
        }
    }



}
